package com.lib76.socket;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import com.lib76.socket.model.SocketChannel;

/**
 * Socket通讯管理
 * @author 张浩
 * @version 1.0.2
 */
public class SocketChannelManager {

	private final static ConcurrentMap<Integer, SocketChannel> SOCKET_CHANNEL_STORE = new ConcurrentHashMap<Integer, SocketChannel>();

	public static void addSocketChannel(SocketChannel channel){
		SOCKET_CHANNEL_STORE.put(channel.getId(), channel);
	}
	
	public static void removeSocketChannel(Integer channelId){
		if(channelId != null){
			SOCKET_CHANNEL_STORE.remove(channelId);
		}
	}
	
	public static SocketChannel getSocketChannel(Integer channelId){
		if(channelId != null){
			return SOCKET_CHANNEL_STORE.get(channelId);
		}
		return null;
	}
}
